package person.bing.fbcloud.common.log.config;

import lombok.AllArgsConstructor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import person.bing.fbcloud.common.log.aop.SysLogAop;
import person.bing.fbcloud.common.log.event.SysLogListener;
import person.bing.fbcloud.service.UpmsService;

/**
 * @author: mengfanbing
 * @date: 2020/5/18 13:30
 * 自动配置
 */
@EnableAsync
@Configuration
@AllArgsConstructor
@ConditionalOnWebApplication
public class LogAutoConfiguration {
    private final UpmsService upmsService;

    @Bean
    public SysLogAop sysLogAop(ApplicationEventPublisher publisher){
        return new SysLogAop(publisher);
    }

    @Bean
    public SysLogListener sysLogListener(){
        return new SysLogListener(upmsService);
    }
}
